package com.lanou.renrenxin.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.volley.toolbox.NetworkImageView;
import com.easemob.EMCallBack;
import com.easemob.chat.EMChatManager;
import com.easemob.chat.EMConversation;
import com.easemob.chat.EMMessage;
import com.easemob.chat.FileMessageBody;
import com.easemob.chat.ImageMessageBody;
import com.easemob.chat.LocationMessageBody;
import com.easemob.chat.TextMessageBody;
import com.easemob.chat.VoiceMessageBody;
import com.lanou.renrenxin.R;
import com.lanou.renrenxin.custommodule.CircleImageView;
import com.lanou.renrenxin.custommodule.ProcessImageView;
import com.lanou.renrenxin.onclicklistener.OnChattingItemClickListener;
import com.lanou.renrenxin.singleton.RenrenxinSingleton;
import com.lanou.renrenxin.tools.FileIconJudge;
import com.lanou.renrenxin.tools.LogUtils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by zouhui on 16/3/3.
 */
public class ChattingAdapter extends RecyclerView.Adapter {
    private final static int MSG_TYPE_RECEIVE = 1;
    private final static int MSG_TYPE_SEND = 2;
    private final static int MSG_TYPE_SEND_TXT = 21;//文本
    private final static int MSG_TYPE_SEND_VOICE = 22;//声音
    private final static int MSG_TYPE_SEND_VIDEO = 23;//视频
    private final static int MSG_TYPE_SEND_FILE = 24;//文件
    private final static int MSG_TYPE_SEND_LOCATION = 25;//定位
    private final static int MSG_TYPE_SEND_IMAGE = 26;//图片
    private final static int MSG_TYPE_RECEIVE_TXT = 11;
    private final static int MSG_TYPE_RECEIVE_VOICE = 12;//声音
    private final static int MSG_TYPE_RECEIVE_VIDEO = 13;//视频
    private final static int MSG_TYPE_RECEIVE_FILE = 14;//文件
    private final static int MSG_TYPE_RECEIVE_LOCATION = 15;//定位
    private final static int MSG_TYPE_RECEIVE_IMAGE = 16;//图片
    private Context context;
    private EMConversation conversation;
    private String toUserName;
    private String mUsernmae;
    private OnChattingItemClickListener onChattingItemClickListener;
    private ProgressBar progressBar = null;
    private List<EMMessage> emMessageList;
    private Bitmap bitmapHeadMy;
    private Bitmap bitmapHeadfriend;

    public void setOnChattingItemClickListener(OnChattingItemClickListener onChattingItemClickListener) {
        this.onChattingItemClickListener = onChattingItemClickListener;

    }


    public ChattingAdapter(Context context, String toUserName, String mUsernmae) {
        this.context = context;
        this.toUserName = toUserName;
        this.mUsernmae = mUsernmae;
        initData();
    }

    private void initData() {
        emMessageList = new ArrayList<>();
        conversation = EMChatManager.getInstance().getConversation(toUserName);
        emMessageList = conversation.getAllMessages();
        bitmapHeadMy = RenrenxinSingleton.getInstence().getDiskBitmap(
                RenrenxinSingleton.getInstence().getImageUrl(toUserName));
        bitmapHeadMy = RenrenxinSingleton.getInstence().getDiskBitmap(
                RenrenxinSingleton.getInstence().getImageUrl(mUsernmae));
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        if (viewType == MSG_TYPE_RECEIVE_TXT) {//接收文本布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_receive_txt, parent, false);
            ChattingReceiveViewHolder chattingReceiveViewHolder = new ChattingReceiveViewHolder(view);
            return chattingReceiveViewHolder;
        }

        if (viewType == MSG_TYPE_RECEIVE_VOICE) {//接收语音布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_receive_voice, parent, false);
            ChattingReceiveVoiceViewHolder receiveVoiceViewHolder = new ChattingReceiveVoiceViewHolder(view);
            return receiveVoiceViewHolder;
        }

        if (viewType == MSG_TYPE_SEND_VOICE) {//发送语音布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_send_vocie, parent, false);
            ChattingSendVoiceViewHolder sendVoiceViewHolder = new ChattingSendVoiceViewHolder(view);
            return sendVoiceViewHolder;
        }

        if (viewType == MSG_TYPE_SEND_IMAGE) {//发送图片消息布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_send_image, parent, false);
            ChattingSendImageViewHolder chattingSendImageViewHolder =
                    new ChattingSendImageViewHolder(view);
            return chattingSendImageViewHolder;
        }

        if (viewType == MSG_TYPE_RECEIVE_IMAGE) {//接收图片消息布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_receive_image, parent, false);
            ChattingReceiveImageViewHolder chattingReceiveImageViewHolder =
                    new ChattingReceiveImageViewHolder(view);
            return chattingReceiveImageViewHolder;
        } else if (viewType == MSG_TYPE_SEND_LOCATION) {//发送位置信息
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_send_location, parent, false);
            ChattingSendLocationViewHolder sendLocationViewHolder =
                    new ChattingSendLocationViewHolder(view);
            return sendLocationViewHolder;
        } else if (viewType == MSG_TYPE_RECEIVE_LOCATION) {//接收位置信息
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_receive_location, parent, false);
            ChattingReceiveLocationViewHolder receiveLocationViewHolder =
                    new ChattingReceiveLocationViewHolder(view);
            return receiveLocationViewHolder;
        } else if (viewType == MSG_TYPE_SEND_FILE) {//发送文件布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_send_file, parent, false);
            ChattingSendFileViewHolder sendFileViewHolder =
                    new ChattingSendFileViewHolder(view);
            return sendFileViewHolder;
        } else if (viewType == MSG_TYPE_RECEIVE_FILE) {//接收文件布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_receive_file, parent, false);
            ChattingReceiveFileViewHolder receiveFileViewHolder =
                    new ChattingReceiveFileViewHolder(view);
            return receiveFileViewHolder;
        } else {//发送文本布局
            View view = LayoutInflater.from(context).inflate(
                    R.layout.item_recycle_chatting_send_txt, parent, false);
            ChattingSendViewHolder chattingSendViewHolder =
                    new ChattingSendViewHolder(view);
            return chattingSendViewHolder;
        }

    }


    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        final EMMessage emMessage = emMessageList.get(position);
        String username = EMChatManager.getInstance().getCurrentUser();
        if (getItemViewType(position) == MSG_TYPE_SEND_TXT) {//发送文本消息
            ChattingSendViewHolder chattingSendViewHolder = (ChattingSendViewHolder) holder;
            if (bitmapHeadMy!=null){
                chattingSendViewHolder.headImg.setImageBitmap(bitmapHeadMy);
            }else {
                chattingSendViewHolder.headImg.setImageResource(R.mipmap.headimg);
            }
            if (emMessage.status == EMMessage.Status.SUCCESS ||
                    emMessage.status == EMMessage.Status.FAIL) {
                chattingSendViewHolder.progressBar.setVisibility(View.GONE);
            }
            if (emMessage.status == EMMessage.Status.INPROGRESS) {
                chattingSendViewHolder.progressBar.setProgress(emMessage.progress);
            }
            chattingSendViewHolder.pos = position;
            final String content = ((TextMessageBody) emMessage.getBody()).getMessage();
            final String msgId = emMessage.getMsgId();
            chattingSendViewHolder.body.setText(content);
            progressBar = chattingSendViewHolder.progressBar;
            chattingSendViewHolder.body.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {

                    onChattingItemClickListener.onChattingItemLongClick(mUsernmae, content, msgId, emMessage);
                    return false;
                }
            });
            chattingSendViewHolder.headImg.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.onHeadImgClick(mUsernmae);
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_RECEIVE_TXT) {//接收文本消息
            ChattingReceiveViewHolder chattingReceiveViewHolder = (ChattingReceiveViewHolder) holder;

            if (bitmapHeadMy!=null){
                chattingReceiveViewHolder.headImg.setImageBitmap(bitmapHeadfriend);
            }else {
                chattingReceiveViewHolder.headImg.setImageResource(R.mipmap.headimg);
            }
            final String content = ((TextMessageBody) emMessage.getBody()).getMessage();
            final String msgId = emMessage.getMsgId();
            chattingReceiveViewHolder.body.setText(content);
            chattingReceiveViewHolder.body.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    onChattingItemClickListener.onChattingItemLongClick(toUserName, content, msgId, emMessage);

                    return false;
                }
            });
            chattingReceiveViewHolder.headImg.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.onHeadImgClick(toUserName);
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_SEND_VOICE) {//发送语音消息
            final ChattingSendVoiceViewHolder sendVoiceViewHolder = (ChattingSendVoiceViewHolder) holder;

            if (bitmapHeadMy!=null){
                sendVoiceViewHolder.headImg.setImageBitmap(bitmapHeadMy);
            }else {
                sendVoiceViewHolder.headImg.setImageResource(R.mipmap.headimg);
            }

            int length = ((VoiceMessageBody) emMessage.getBody()).getLength();
            String len = "";
            for (int i = 0; i < length; i++) {
                if (i < 15) {
                    len += "  ";
                }
            }
            sendVoiceViewHolder.textView.setText(length + "''" + len);
            sendVoiceViewHolder.pos = position;
            sendVoiceViewHolder.voiceBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.playVoice(((VoiceMessageBody) emMessageList.get(sendVoiceViewHolder.pos).getBody()).getLocalUrl());
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_RECEIVE_VOICE) {//接收语音消息
            final ChattingReceiveVoiceViewHolder receiveVoiceViewHolder = (ChattingReceiveVoiceViewHolder) holder;

            if (bitmapHeadMy!=null){
                receiveVoiceViewHolder.headImg.setImageBitmap(bitmapHeadfriend);
            }else {
                receiveVoiceViewHolder.headImg.setImageResource(R.mipmap.headimg);
            }

            receiveVoiceViewHolder.pos = position;
            int length = ((VoiceMessageBody) emMessage.getBody()).getLength();
            String len = "";
            for (int i = 0; i < length; i++) {
                if (i < 15) {
                    len += "  ";
                }
            }
            receiveVoiceViewHolder.textView.setText(len + length + "''");
            receiveVoiceViewHolder.voiceBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.playVoice(((VoiceMessageBody) emMessageList.get(receiveVoiceViewHolder.pos).getBody()).getRemoteUrl());
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_SEND_IMAGE) {//发送图片消息
            ChattingSendImageViewHolder viewHolder = (ChattingSendImageViewHolder) holder;

            if (bitmapHeadMy!=null){
                viewHolder.headImgBtn.setImageBitmap(bitmapHeadMy);
            }else {
                viewHolder.headImgBtn.setImageResource(R.mipmap.headimg);
            }

            final String imagePath = ((ImageMessageBody) emMessage.getBody()).getLocalUrl();
            Bitmap bitmap = getLoacalBitmap(imagePath);
            viewHolder.imageView.setImageBitmap(bitmap);
            viewHolder.imageView.setProgress(102);
            viewHolder.imageViewSuccess.setImageBitmap(bitmap);
            viewHolder.imageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.onImageClick(imagePath, true);
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_RECEIVE_IMAGE) {//接收图片消息
            ChattingReceiveImageViewHolder viewHolder = (ChattingReceiveImageViewHolder) holder;
            if (bitmapHeadMy!=null){
                viewHolder.headImagBtn.setImageBitmap(bitmapHeadfriend);
            }else {
                viewHolder.headImagBtn.setImageResource(R.mipmap.headimg);
            }
            final String iamgePath = ((ImageMessageBody) emMessage.getBody()).getRemoteUrl();
            RenrenxinSingleton.getInstence().loadNetWorkImage(viewHolder.imageView,
                    ((ImageMessageBody) emMessage.getBody()).getThumbnailUrl());
            viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.onImageClick(iamgePath, false);
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_SEND_LOCATION) {//发送位置信息
            final LocationMessageBody locationMessageBody = (LocationMessageBody) emMessage.getBody();
            ChattingSendLocationViewHolder sendLocationViewHolder = (ChattingSendLocationViewHolder) holder;

            if (bitmapHeadMy!=null){
                sendLocationViewHolder.headImag.setImageBitmap(bitmapHeadMy);
            }else {
                sendLocationViewHolder.headImag.setImageResource(R.mipmap.headimg);
            }

            sendLocationViewHolder.locationTv.setText(locationMessageBody.getAddress());
            sendLocationViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.onLocationItemClick(
                            locationMessageBody.getLatitude(), locationMessageBody.getLongitude());
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_RECEIVE_LOCATION) {//接收位置信息
            final LocationMessageBody locationMessageBody = (LocationMessageBody) emMessage.getBody();
            ChattingReceiveLocationViewHolder receiveLocationViewHolder = (ChattingReceiveLocationViewHolder) holder;
            receiveLocationViewHolder.locationTv.setText(locationMessageBody.getAddress());
            receiveLocationViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onChattingItemClickListener.onLocationItemClick(
                            locationMessageBody.getLatitude(), locationMessageBody.getLongitude());
                }
            });
        } else if (getItemViewType(position) == MSG_TYPE_SEND_FILE) {//发送文件
            ChattingSendFileViewHolder sendFileViewHolder = (ChattingSendFileViewHolder) holder;
            String fileName = ((FileMessageBody) emMessage.getBody()).getFileName();
            sendFileViewHolder.fileClass.setImageResource(FileIconJudge.judgeFileIcon(fileName));
            sendFileViewHolder.fileSize.setText("10M");
            sendFileViewHolder.fileStatus.setText("未下载");
            if (fileName.length() < 10) {
                fileName += "                ";
            }
            sendFileViewHolder.fileTv.setText(fileName);
        } else if (getItemViewType(position) == MSG_TYPE_RECEIVE_FILE) {//接收文件
            ChattingReceiveFileViewHolder receiveFileViewHolder = (ChattingReceiveFileViewHolder) holder;
            String fileName = ((FileMessageBody) emMessage.getBody()).getFileName();
            receiveFileViewHolder.fileClass.setImageResource(FileIconJudge.judgeFileIcon(fileName));
            receiveFileViewHolder.fileSize.setText("10M");
            receiveFileViewHolder.fileStatus.setText("未下载");
            if (fileName.length() < 10) {
                fileName += "                ";
            }
            receiveFileViewHolder.fileTv.setText(fileName);
        }
    }

    @Override
    public int getItemCount() {
        return null == emMessageList ? 0 : emMessageList.size();
    }

    @Override
    public int getItemViewType(int position) {
        EMMessage emMessage = emMessageList.get(position);
        if (emMessage.getFrom().equals(toUserName)) {//接收
            if (emMessage.getType() == EMMessage.Type.TXT)//文本
                return MSG_TYPE_RECEIVE_TXT;
            if (emMessage.getType() == EMMessage.Type.FILE)//文件
                return MSG_TYPE_RECEIVE_FILE;
            if (emMessage.getType() == EMMessage.Type.IMAGE)//图片
                return MSG_TYPE_RECEIVE_IMAGE;
            if (emMessage.getType() == EMMessage.Type.LOCATION)//定位
                return MSG_TYPE_RECEIVE_LOCATION;
            if (emMessage.getType() == EMMessage.Type.VIDEO)//视频
                return MSG_TYPE_RECEIVE_VIDEO;
            if (emMessage.getType() == EMMessage.Type.VOICE)//语音
                return MSG_TYPE_RECEIVE_VOICE;
        } else {//发送
            if (emMessage.getType() == EMMessage.Type.TXT)//文本
                return MSG_TYPE_SEND_TXT;
            if (emMessage.getType() == EMMessage.Type.FILE)//文件
                return MSG_TYPE_SEND_FILE;
            if (emMessage.getType() == EMMessage.Type.IMAGE)//图片
                return MSG_TYPE_SEND_IMAGE;
            if (emMessage.getType() == EMMessage.Type.LOCATION)//定位
                return MSG_TYPE_SEND_LOCATION;
            if (emMessage.getType() == EMMessage.Type.VIDEO)//视频
                return MSG_TYPE_SEND_VIDEO;
            if (emMessage.getType() == EMMessage.Type.VOICE)//语音
                return MSG_TYPE_SEND_VOICE;
        }
        return MSG_TYPE_SEND;
    }


    private Bitmap getLoacalBitmap(String url) {
        try {
            FileInputStream fis = new FileInputStream(url);
            return BitmapFactory.decodeStream(fis);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }


    public void send(EMMessage message) {
        sendMessage(message);
        notifyDataSetChanged();
    }


    private void sendMessage(EMMessage message) {
        EMChatManager.getInstance().sendMessage(message, new EMCallBack() {
            @Override
            public void onSuccess() {
                LogUtils.e("ChattingAdapter", "发送成功");
            }

            @Override
            public void onError(int i, String s) {
                LogUtils.e("ChattingAdapter", "发送失败");
            }

            @Override
            public void onProgress(int i, String s) {
            }
        });

    }


    /***************************
     * 接收信息缓存类
     *******************************/
    /**
     * 接收文本
     */
    class ChattingReceiveViewHolder extends RecyclerView.ViewHolder {
        private TextView body;
        private CircleImageView headImg;

        public ChattingReceiveViewHolder(View itemView) {
            super(itemView);
            body = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_receive_txt);
            headImg = (CircleImageView) itemView.findViewById(R.id.imgBtn_item_recycle_chatting_receive_txt_headimg);
        }
    }

    /**
     * 接收语音
     */
    public class ChattingReceiveVoiceViewHolder extends RecyclerView.ViewHolder {
        public ImageButton voiceBtn;
        private CircleImageView headImg;
        private TextView textView;
        private int pos;

        public ChattingReceiveVoiceViewHolder(View itemView) {
            super(itemView);
            voiceBtn = (ImageButton) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_receive_voice_content);
            headImg = (CircleImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_receive_voice_headimg);
            textView = (TextView) itemView.findViewById(
                    R.id.tv_item_recycle_chatting_receive_voice_kong);
            pos = 0;
        }
    }

    /**
     * 接收图片
     */
    class ChattingReceiveImageViewHolder extends RecyclerView.ViewHolder {
        private NetworkImageView imageView;
        private CircleImageView headImagBtn;
        int pos = 0;

        public ChattingReceiveImageViewHolder(View itemView) {
            super(itemView);
            imageView = (NetworkImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_receive_image_content);
            headImagBtn = (CircleImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_receive_image_headimg);
            pos = 0;
        }
    }

    /***************************
     * 发送信息缓存类
     *******************************/
    public class ChattingSendViewHolder extends RecyclerView.ViewHolder {
        public TextView body;
        private CircleImageView headImg;
        public ProgressBar progressBar;
        private int count = 0;
        private int pos = 0;

        public ChattingSendViewHolder(View itemView) {
            super(itemView);
            body = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_send);
            headImg = (CircleImageView) itemView.findViewById(R.id.imgBtn_recycle_chatting_send);
            progressBar = (ProgressBar) itemView.findViewById(R.id.progressbar_sendmsg);
            count = 0;
            pos = 0;
        }
    }

    /**
     * 发送语音缓存类
     */
    public class ChattingSendVoiceViewHolder extends RecyclerView.ViewHolder {
        public ImageButton voiceBtn;
        private CircleImageView headImg;
        private TextView textView;
        private int pos;

        public ChattingSendVoiceViewHolder(View itemView) {
            super(itemView);
            voiceBtn = (ImageButton) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_send_voice_content);
            headImg = (CircleImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_send_voice_headimg);
            textView = (TextView) itemView.findViewById(
                    R.id.tv_item_recycle_chatting_send_voice_kong);
            pos = 0;
        }
    }

    /**
     * 接收位置信息
     */
    private class ChattingReceiveLocationViewHolder extends RecyclerView.ViewHolder {
        private CircleImageView headImg;
        private TextView locationTv;
        int pos = 0;

        public ChattingReceiveLocationViewHolder(View itemView) {
            super(itemView);
            headImg = (CircleImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_receive_location_headimg);
            locationTv = (TextView) itemView.findViewById(
                    R.id.tv_item_recycle_chatting_receive_location_address);
            pos = 0;
        }
    }

    /**
     * 接收文件信息
     */
    private class ChattingReceiveFileViewHolder extends RecyclerView.ViewHolder {//
        private CircleImageView headImg;
        private ImageView fileClass;
        private TextView fileTv, fileSize, fileStatus;
        int pos = 0;

        public ChattingReceiveFileViewHolder(View itemView) {
            super(itemView);
            headImg = (CircleImageView) itemView.findViewById(R.id.imgBtn_item_recycle_chatting_receive_file_headimg);
            fileTv = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_receive_file_content);
            fileSize = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_receive_file_size);
            fileClass = (ImageView) itemView.findViewById(R.id.iv_item_recycle_chatting_receive_file_class);
            fileStatus = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_receive_file_status);
            pos = 0;
        }
    }

    /**
     * 发送图片
     */
    public class ChattingSendImageViewHolder extends RecyclerView.ViewHolder {
        private CircleImageView headImgBtn;
        public ProcessImageView imageView;
        public ImageView imageViewSuccess;
        private int pos = 0;

        public ChattingSendImageViewHolder(View itemView) {
            super(itemView);
            headImgBtn = (CircleImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_send_image_headimg);
            imageView = (ProcessImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_send_image_content_process);
            imageViewSuccess = (ImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_send_image_content);
            pos = 0;
        }
    }

    /**
     * 发送位置信息
     */
    public class ChattingSendLocationViewHolder extends RecyclerView.ViewHolder {
        public CircleImageView headImag;
        public TextView locationTv;
        int pos = 0;

        public ChattingSendLocationViewHolder(View itemView) {
            super(itemView);
            headImag = (CircleImageView) itemView.findViewById(
                    R.id.imgBtn_item_recycle_chatting_send_location_headimg);
            locationTv = (TextView) itemView.findViewById(
                    R.id.tv_item_recycle_chatting_send_location_address);
            pos = 0;
        }
    }

    /**
     * 发送文件缓存类
     */
    private class ChattingSendFileViewHolder extends RecyclerView.ViewHolder {
        private CircleImageView headImg;
        private TextView fileTv, fileSize, fileStatus;
        ImageView fileClass;
        private int pos = 0;

        public ChattingSendFileViewHolder(View itemView) {
            super(itemView);
            headImg = (CircleImageView) itemView.findViewById(R.id.imgBtn_item_recycle_chatting_send_file_headimg);
            fileTv = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_send_file_content);
            fileSize = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_send_file_size);
            fileStatus = (TextView) itemView.findViewById(R.id.tv_item_recycle_chatting_send_file_status);
            fileClass = (ImageView) itemView.findViewById(R.id.iv_item_recycle_chatting_send_file_class);
            pos = 0;
        }
    }
}
